import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 周斌
 * Date: 2024-06-29
 * Time: 16:31
 */
public class Deom5 {
    public static void main(String[] args) throws IOException {
        //版本1：无参数，一个一个从程序写入文件中
        /*try(Writer writer = new FileWriter("./text.txt",true)) {
            writer.write(',');
            writer.write('我');
            writer.write('来');
            writer.write('了');
        }*/
        //版本2：有一个参数，char[]类型，一个数组大小的写入文件
       /* char[] ch = new char[1024];
        for (int i = 0; i < ch.length; i++) {
            ch[i] = '好';
        }*/
       /* try(Writer writer = new FileWriter("./text.txt",true)) {
            writer.write(ch);
        }*/
        //版本3：传String类型的数组
        String str = "hhhhhhhhhhhhhhh";
        try(Writer writer = new FileWriter("./text.txt")) {
            writer.write(str);
        }
    }
}
